package me.yricky

object OSUtils {
    val hostOs: OS by lazy {
        val osName = System.getProperty("os.name")
        when {
            osName == "Mac OS X" -> OS.MacOS
            osName.startsWith("Win") -> OS.Windows
            "The Android Project" == System.getProperty("java.specification.vendor") -> OS.Android
            osName == "Linux" -> OS.Linux
            else -> throw Error("Unknown OS $osName")
        }
    }

    val hostArch: Arch by lazy {
        when (val osArch = System.getProperty("os.arch")) {
            "x86_64", "amd64" -> Arch.X64
            "aarch64" -> Arch.Arm64
            else -> throw Error("Unknown arch $osArch")
        }
    }

    enum class OS(val id: String) {
        Android("android"),
        Linux("linux"),
        Windows("windows"),
        MacOS("macos"),
        ;
    }

    enum class Arch(val id: String) {
        X64("x64"),
        Arm64("arm64"),
    }
}